<template>
	<page-container :title='false'>
		<a-card :bordered='false' style='margin-top: 24px'>
			<div class='table-operator'>
				<a-form layout='inline'>
					<template v-if='userInfo.type === 3'>
						<a-form-item>
							<a-input placeholder='输入封签码' v-model='queryParam.seal_code' />
						</a-form-item>
						<a-form-item>
							<a-button type='primary' @click='handleCode' icon='search'>封签码找订单</a-button>
						</a-form-item>
					</template>
					<a-form-item>
						<a-range-picker @change='onChange'>
							<a-icon slot='suffixIcon' type='calendar' />
						</a-range-picker>
					</a-form-item>
					<a-form-item>
						<a-input placeholder='姓名/手机号/订单号' v-model='queryParam.search' />
					</a-form-item>
					<a-form-item>
						<a-select placeholder='线上/线下' v-model='queryParam.is_offline' style='width: 200px' allowClear>
							<a-select-option :value='0'>线上</a-select-option>
							<a-select-option :value='1'>线下</a-select-option>
						</a-select>
					</a-form-item>
					<a-form-item>
						<a-select placeholder='订单状态' v-model='queryParam.is_take' allowClear style='width: 200px'>
							<a-select-option :value='key' v-for='(item,key) in isTakeList' :key='key'>{{ item }}</a-select-option>
						</a-select>
					</a-form-item>
					<a-form-item>
						<a-button type='primary' @click='refreshTable' icon='search'>查询</a-button>
					</a-form-item>
					<a-form-item>
						<a-button type='primary' @click="handleExportXls('洗衣订单')" icon='download'>下载</a-button>
					</a-form-item>
				</a-form>
			</div>
			<clothes-order-table :data='loadData' ref='orderTable' />

		</a-card>
	</page-container>
</template>

<script>
	import {
		clothesOrder,
		clothesDown,
		clothesOrderPush,
		zoneBindCityLists
	} from '@/api/clothes'
	import {
		mapGetters
	} from 'vuex'
	import {
		IS_TAKE,
		EXPRESS_STATUS
	} from '@/mixins/orderStatus'
	import StewardRatioForm from '@/views/store/modules/stewardRatioForm'
	import StewardGatherForm from '@/views/store/modules/stewardGatherForm'
	import StewardForm from '@/views/store/modules/StewardForm'
	import clothesOrderTable from '@/components/clothesOrderTable'
	import StoreInfoWrap from '@/views/store/modules/StoreInfoWrap'
	import formTableMixin from '@/mixins/formTableMixin'

	export default {
		name: 'ClothesOrder',
		mixins: [formTableMixin],
		components: {
			StewardRatioForm,
			StewardForm,
			StoreInfoWrap,
			clothesOrderTable,
			StewardGatherForm,
		
		},
		data() {
			return {
				queryParam: {
					search: '',
					atime: '',
					etime: '',
					seal_code: '',
					send_worker_from:'jd'
				},
				isTakeList: EXPRESS_STATUS,
				loadData: parameter => {
					const params = this.$route.query || {}
					const requestParameters = Object.assign({
						id: params.id
					}, parameter, this.queryParam)
					console.log('loadData request parameters:', requestParameters)
					return clothesOrder(requestParameters).then(res => {
						return res.data
					})
				},
				downAction: parameter => {
					const params = {
						...parameter,
						id: (this.$route.params || {}).store_id
					}
					return clothesDown(params)
				},
				loadingStore: false,
				orderPushing: false // 语音播报状态
			}
		},

		created() {
			// let express = Object.assign({}, EXPRESS_STATUS)
			// console.log(express)
			// this.isTakeList = express
			// console.log(this.isTakeList)
			// console.log(express)
			// console.log(IS_TAKE)
		},
		computed: {
			...mapGetters(['userInfo'])
		},
		methods: {

			onChange(date, dateString) {
				console.log(date, dateString)
				this.queryParam.atime = dateString[0]
				this.queryParam.etime = dateString[1]
			},
			handleCode() {
				const sealCode = this.queryParam.seal_code
				if (!sealCode) {
					this.$message.warning('请输入封签码')
					return
				}
				this.$router.push({
					name: 'clothesOrderDetail',
					// path: '/clothes/clothes-order-detail',
					query: {
						seal_code: sealCode
					}
				})
			},
			refreshTable() {
				this.$refs.orderTable.handleSearch(true)
			}
		}
	}
</script>